package com.cq.hd.order.mq.provider;

import com.cq.hd.common.constant.RabbitMqConstant;
import com.cq.hd.common.utils.GenerateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
@Slf4j
public class OrderVerifyMsgProvider {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void sendMsg(Long orderId) {
        Map<String, Object> map = new HashMap<>(2);
        map.put("messageId", GenerateUtil.getMsg("order-verify"));
        map.put("messageData", String.valueOf(orderId));
        log.info("发送订单核销消息：" + map.toString());

//        CorrelationData correlationData = new CorrelationData();
//        correlationData.setId(msgId);
//        rabbitTemplate.convertAndSend(RabbitMqConstant.BUSINESS_ENTER_EXCHANGE_DIRECT, RabbitMqConstant.BUSINESS_ENTER_ROUTING_KEY, map, correlationData);

        rabbitTemplate.convertAndSend(RabbitMqConstant.ORDER_VERIFY_EXCHANGE_DIRECT, RabbitMqConstant.ORDER_VERIFY_ROUTING_KEY, map);
    }

}
